<template>
  <div class="base-wallet-info box fz-14">
    <div>
      <span>钱包地址：</span>
      <span>{{ fromAddressHideRef }}</span>
    </div>

    <div>
      <span class="cl-success">USDT：</span>
      <span>{{ usdtBalance }}</span>
    </div>

    <div>
      <span class="cl-success">HASH：</span>
      <span>{{ usdtBalance }}</span>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { showError, toNumber } from 'js/utils'

const fromAddressHideRef = ref(window.fromAddressHide)
const usdtBalance = ref(0)

onMounted(async () => {
  // usdtBalance.value = await getUserAmount()
})

// 获取用户钱包余额
function getUserAmount() {
  return new Promise(async (resolve, reject) => {
    try {
      console.log('获取账户余额')
      const balance = await usdtContract.context.methods
        .balanceOf(fromAddress)
        .call()
      const balanceInBigNumber = toNumber(balance)
      console.log(`获取账户余额成功：${balanceInBigNumber}`)
      resolve(balanceInBigNumber)
    } catch (err) {
      showError('获取账户余额失败')
      console.error('获取账户余额失败')
      console.error(err)
      reject(err)
    }
  })
}
</script>

<style lang="scss" scoped></style>
